/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package struts;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import test.Test;

/**
 *
 * @author Alex
 */
public class AddStringAction extends ActionSupport
{
    //Test testBean = lookupTestBeanRemote();
    private String string;

    public void setString(String string) {
        this.string = string;
    }
    

    @Override
    public String execute()
    {
        //testBean.add(string);
        Test testBean = (Test) ActionContext.getContext().getSession().get("ejb");

        testBean.add(string);

        return SUCCESS;
        
    }

    private Test lookupTestBeanRemote() {
        try {
            Context c = new InitialContext();
            return (Test) c.lookup("test.Test");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }
}
